package umt.cs.cs241.Assignment1.r_1_2;

/*
 * Chris Hanshew
 * CS 241 Assignment 1
 * 9/9/08
 * R 1.2 Credit Card
 * 
 * Source from web
 */

public class CreditCard {
	
	  // Instance variables:
	  private String number;
	  private String name;
	  private String bank;
	  private double balance;
	  private double interest;
	  private int limit;
	  
	  // Constructor:
	  CreditCard(String no, String nm, String bk, double bal, int lim) {
	    number = no;
	    name = nm;
	    bank = bk;
	    balance = bal;
	    limit = lim;
	    
	    interest = 0.0025; //Interest var
	  }
	  
	  // Accessor methods:
	  public String getNumber() { return number; }
	  public String getName() { return name; }
	  public String getBank() { return bank; }
	  public double getBalance() { return balance; }
	  public int getLimit() { return limit; }
	  
	  // Action methods:
	  public boolean chargeIt(double price) { // Make a charge 
	    if (price + balance > (double) limit) 
	      return false; // There is not enough money left to charge it
	    balance += price;
	    return true; // The charge goes through in this case
	  }
	  public void makePayment(double payment) { // Make a payment
		  
		balance += balance * interest;  //increment interest
		
	    balance -= payment; 
	  }
	  public static void printCard(CreditCard c) { // Print a card's information 
	    System.out.println("Number = " + c.getNumber());
	    System.out.println("Name = " + c.getName());
	    System.out.println("Bank = " + c.getBank());
	    System.out.println("Balance = " + c.getBalance()); // Implicit cast
	    System.out.println("Limit = " + c.getLimit()); // Implicit cast
	  }
	}
